package models;

import java.util.*;
import javax.persistence.*;

import play.Logger;
import play.data.format.*;
import play.data.validation.*;

public class RegisterForm {

	@Constraints.Required
	@Formats.NonEmpty
	public String username;

	@Constraints.Required
	@Formats.NonEmpty
	public String password;
	
	@Constraints.Required
	@Formats.NonEmpty
	public String confirmPassword;

	@Constraints.Required
	@Constraints.Email
	@Formats.NonEmpty	
	public String email;
	
	
	@Constraints.Required
	@Formats.NonEmpty
	@Constraints.Pattern(value = "[0-9]+", message="Must be numeric")
	public String credit_card;
	
	public String lang;
	

	public String validate() {
		if(!password.equals(confirmPassword)) {
			return "register.error.mismatch";
		}
		
		if(User.isUsernameExists(username))
			return "register.error.userAlreadyExists";		
		
		return null;
	}


}

